<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="root">
        <!-- 使用学校组件 -->

    </div>
    <script>
        //定义学生组件
        const student = Vue.extend({
                template: `<div>
               <h2>学生名称:{{studentName}}</h2>
                <h2>学生年龄:{{age}}</h2>
                </div>`,
                data() {
                    return {
                        studentName: '王万兴',
                        age: 18
                    }
                }
            })
            //定义学校组件
        const school = Vue.extend({
                // 使用app组件
                template: `<div>
                <h2>学校名称:{{schoolName}}</h2>
                <h2>学校地址:{{address}}</h2>
                <student></student>
                </div>`,
                data() {
                    return {
                        schoolName: '应技大',
                        address: '奉贤'
                    }
                },
                //注册学生组件
                components: {
                    student
                }
            })
            // 定义app组件
        const app = Vue.extend({

            template: `<div><school></school></div>`,
            components: {
                school
            }
        })
        new Vue({
            //使用app组件
            template: `<app></app>`,
            el: '#root',
            //注册app组件
            components: {
                app
            }
        })
    </script>
</body>

</html>